package org.mis6323.data.dao.impl;

import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.mis6323.data.dao.ProviderDao;
import org.mis6323.data.model.Provider;


public class DatabaseProviderDaoImp implements ProviderDao{

    SqlSession sqlSession;

    public void setSqlSession(SqlSession sqlSession){
        this.sqlSession=sqlSession;
    }
    public void createProvider(Provider provider){
        this.sqlSession.insert("insertProvider",provider);
    }

    public void deleteProvider(Long provideId){
        this.sqlSession.delete("deleteProvider",provideId);
    }

    public void updateProvider(Provider provider){
        this.sqlSession.update("updateProvider",provider);
    }

    public Provider searchProviderById(Long providerId){
        return (Provider) this.sqlSession.selectOne("selectProviderById",providerId);
    }


    public Provider searchProviderByFullName(String phoneNo) {
        return (Provider) this.sqlSession.selectOne("selectProviderByPhoneNo",phoneNo);
    }

    @Override
    public List<Provider> getAllProviders() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
